package com.burgeon.backend.SHOPBACKEND.controller;
/**
 *
 */

import com.burgeon.backend.SHOPBACKEND.entity.Employee;
import com.burgeon.backend.SHOPBACKEND.service.BackendEmployeeService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Arrays;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("backend/emp")
public class BackendEmployeeController extends BaseController {
    @Autowired
    private BackendEmployeeService backendEmployeeService;




    @RequestMapping("businessCard")
    public ResponseResult<String> businessCard (String[] ids,String account) {
        System.err.println(Arrays.toString(ids));
        System.err.println(account);
        String data = backendEmployeeService.createBusinessCard(ids, account);
        return new ResponseResult<String>(SUCCESS,data);
    }

    @RequestMapping("uploading")
    public ResponseResult<Void> uploading(String id,MultipartFile img, String account) {
        backendEmployeeService.uploading(id,img,account);
        return new ResponseResult<>(SUCCESS);
    }

    @RequestMapping("listData")
    public ResponseResult<List<Employee>> listData(String account) {
        List<Employee> data = backendEmployeeService.listData(account);
        return new ResponseResult<List<Employee>>(SUCCESS,data);

    }
}
